<!doctype html>
<html>
  <head>
    <!-- MathJax -->
    <script type="text/javascript"
      src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
    </script>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="chrome=1">
    <title>
      Caffe | Installation: Ubuntu
    </title>

    <link rel="icon" type="image/png" href="/images/caffeine-icon.png">

    <link rel="stylesheet" href="/stylesheets/reset.css">
    <link rel="stylesheet" href="/stylesheets/styles.css">
    <link rel="stylesheet" href="/stylesheets/pygment_trac.css">

    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <!--[if lt IE 9]>
    <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
  </head>
  <body>
  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-46255508-1', 'daggerfs.com');
    ga('send', 'pageview');
  </script>
    <div class="wrapper">
      <header>
        <h1 class="header"><a href="/">Caffe</a></h1>
        <p class="header">
          Deep learning framework by <a class="header name" href="http://bair.berkeley.edu/">BAIR</a>
        </p>
        <p class="header">
          Created by
          <br>
          <a class="header name" href="http://daggerfs.com/">Yangqing Jia</a>
          <br>
          Lead Developer
          <br>
          <a class="header name" href="http://imaginarynumber.net/">Evan Shelhamer</a>
        <ul>
          <li>
            <a class="buttons github" href="https://github.com/BVLC/caffe">View On GitHub</a>
          </li>
        </ul>
      </header>
      <section>

      <h1 id="ubuntu-installation">Ubuntu Installation</h1>

<h3 id="for-ubuntu--1704">For Ubuntu (&gt;= 17.04)</h3>

<p><strong>Installing pre-compiled Caffe</strong></p>

<p>Everything including caffe itself is packaged in 17.04 and higher versions.
To install pre-compiled Caffe package, just do it by</p>

<div class="highlighter-rouge"><pre class="highlight"><code>sudo apt install caffe-cpu
</code></pre>
</div>

<p>for CPU-only version, or</p>

<div class="highlighter-rouge"><pre class="highlight"><code>sudo apt install caffe-cuda
</code></pre>
</div>

<p>for CUDA version. Note, the cuda version may break if your NVIDIA driver
and CUDA toolkit are not installed by APT.</p>

<p><a href="https://launchpad.net/ubuntu/+source/caffe">Package status of CPU-only version</a></p>

<p><a href="https://launchpad.net/ubuntu/+source/caffe-contrib">Package status of CUDA version</a></p>

<p><strong>Installing Caffe from source</strong></p>

<p>We may install the dependencies by merely one line</p>

<div class="highlighter-rouge"><pre class="highlight"><code>sudo apt build-dep caffe-cpu        # dependencies for CPU-only version
sudo apt build-dep caffe-cuda       # dependencies for CUDA version
</code></pre>
</div>

<p>It requires a <code class="highlighter-rouge">deb-src</code> line in your <code class="highlighter-rouge">sources.list</code>.
Continue with <a href="installation.html#compilation">compilation</a>.</p>

<h3 id="for-ubuntu--1704-1">For Ubuntu (&lt; 17.04)</h3>

<p><strong>General dependencies</strong></p>

<div class="highlighter-rouge"><pre class="highlight"><code>sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
</code></pre>
</div>

<p><strong>CUDA</strong>: Install by <code class="highlighter-rouge">apt-get</code> or the NVIDIA <code class="highlighter-rouge">.run</code> package.
The NVIDIA package tends to follow more recent library and driver versions, but the installation is more manual.
If installing from packages, install the library and latest driver separately; the driver bundled with the library is usually out-of-date.
This can be skipped for CPU-only installation.</p>

<p><strong>BLAS</strong>: install ATLAS by <code class="highlighter-rouge">sudo apt-get install libatlas-base-dev</code> or install OpenBLAS by <code class="highlighter-rouge">sudo apt-get install libopenblas-dev</code> or MKL for better CPU performance.</p>

<p><strong>Python</strong> (optional): if you use the default Python you will need to <code class="highlighter-rouge">sudo apt-get install</code> the <code class="highlighter-rouge">python-dev</code> package to have the Python headers for building the pycaffe interface.</p>

<p><strong>Compatibility notes, 16.04</strong></p>

<p>CUDA 8 is required on Ubuntu 16.04.</p>

<p><strong>Remaining dependencies, 14.04</strong></p>

<p>Everything is packaged in 14.04.</p>

<div class="highlighter-rouge"><pre class="highlight"><code>sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
</code></pre>
</div>

<p><strong>Remaining dependencies, 12.04</strong></p>

<p>These dependencies need manual installation in 12.04.</p>

<div class="highlighter-rouge"><pre class="highlight"><code># glog
wget https://github.com/google/glog/archive/v0.3.3.tar.gz
tar zxvf v0.3.3.tar.gz
cd glog-0.3.3
./configure
make &amp;&amp; make install
# gflags
wget https://github.com/schuhschuh/gflags/archive/master.zip
unzip master.zip
cd gflags-master
mkdir build &amp;&amp; cd build
export CXXFLAGS="-fPIC" &amp;&amp; cmake .. &amp;&amp; make VERBOSE=1
make &amp;&amp; make install
# lmdb
git clone https://github.com/LMDB/lmdb
cd lmdb/libraries/liblmdb
make &amp;&amp; make install
</code></pre>
</div>

<p>Note that glog does not compile with the most recent gflags version (2.1), so before that is resolved you will need to build with glog first.</p>

<p>Continue with <a href="installation.html#compilation">compilation</a>.</p>


      </section>
  </div>
  </body>
</html>
